package mysql
import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
    _ "github.com/go-sql-driver/mysql"
)

type dao_s struct {
	user, pass, url, port, db string  
}

func init(){
	//TODO
	var dao = new(dao_s)  
	dao.user =beego.AppConfig.String("mysqluser")
	dao.pass =beego.AppConfig.String("mysqlpass")
	dao.url =beego.AppConfig.String("mysqlurl")
	dao.port =beego.AppConfig.String("mysqlport")
	dao.db =beego.AppConfig.String("mysqldb")
		
	orm.RegisterDriver("mysql", orm.DRMySQL)
	orm.RegisterDataBase("default", "mysql", dao.user+":"+dao.pass+"@tcp("+dao.url+":"+dao.port+")/"+dao.db+"?charset=utf8",30,30)
}

func GetDbObj() orm.Ormer{
	return orm.NewOrm()
}

/*
func main(){
	o := GetDbObj()
	fmt.Print(o)
}
*/